<template>
  <normal-layout page-index="2-2">
    <el-tabs style="margin: 10px">
      <el-tab-pane label="在售列表">
        <vehicle-table :vehicleList="vehicleList" @updated="getVehicleList" @purchased="getPurchaseList"></vehicle-table>
      </el-tab-pane>
      <el-tab-pane label="库存详情">
        <stock-table :stockList="stockList"></stock-table>
      </el-tab-pane>
      <el-tab-pane label="采购详情">
        <purchase-table :purchaseList="purchaseList" @delivered="getData"></purchase-table>
      </el-tab-pane>
    </el-tabs>
  </normal-layout>
</template>

<script>
  import NormalLayout from "../../layouts/NormalLayout";
  import StockTable from "../../components/Management/StockTable";
  import VehicleTable from "../../components/Management/VehicleTable";
  import PurchaseTable from "../../components/Management/PurchaseTable";
  export default {
    name: "index",
    components: {PurchaseTable, VehicleTable, StockTable, NormalLayout},
    data(){
      return{
        /*库存列表*/
        stockList: [],
        /*在售车型列表*/
        vehicleList: [],
        purchaseList: [],
      }
    },
    mounted() {
      this.getData();
    },
    methods:{
      async getData(){
        console.log('getdata');
        this.getVehicleList();
        this.getStockList();
        this.getPurchaseList();
      },
      /*获取库存列表*/
      async getStockList(){
        this.$axios.get('/get_store_table').then(res=>{
          this.stockList=res.data;
        })
      },
      /*获取在售车型表*/
      async getVehicleList(){
        this.$axios.get('/get_onsale_table').then(res=>{
          this.vehicleList=res.data;
        })
      },
      /*获取订购订单表*/
      async getPurchaseList(){
        this.$axios.get('/get_vorder_table').then(res=>{
          this.purchaseList=res.data;
          console.log(this.purchaseList);
        })
      }
    },
  }
</script>

<style scoped>

</style>
